#include <bits/stdc++.h>
using namespace std;
//#define int long long

using ll = long long;

constexpr int N = 3e5 + 5, MOD = 1e9 + 7, HSMOD = 1610612741, HSMOD2 = 998244353; // Remember to change

int n, r, a, b, idx;
array<basic_string<int>, N> G;
array<int, N> dfn;
array<int, N> da, dsa;

array<int, N> f, g, h, sz, dep;
array<array<int, 20>, N> faf;
array<vector<int>, N> son;

void dfs(int u, int f)
{
	dep[u] = dep[f] + 1;
	faf[u][0] = f;
	sz[u] = 1;
	dfn[u] = ++idx;
	for (auto &j : G[u])
	{
		if (j ^ f) dfs(j, u), sz[u] += sz[j];
	}
}

inline int get_k_fa(int u, int k)
{
	int c = 0;
	while (k)
	{
		if (k & 1) u = faf[u][c];
		k >>= 1;
		c++;
	}
	return u;
}

struct Op
{
	int u, type, val;
	// type = 0: f
	// type = 1: h
	// type = 2: g
	bool operator<(const Op& x) const
	{
		if (val != x.val) return val > x.val;
		return (type < x.type);
	}
	Op() = default;
	Op(int u, int type, int val): u(u), type(type), val(val){}
};

basic_string<Op> ve;

class SegmentTree
{
public:
	struct Node
	{
		int l, r, tag;
	};
	array<Node, N << 2> tr;
	void build(int u, int l, int r)
	{
		tr[u] = { l, r, (int)1e9 };
		if (l == r) return;
		int mid = l + r >> 1;
		build(u << 1, l, mid);
		build(u << 1 | 1, mid + 1, r);
	}
	inline void update(int u, int l, int r, int x)
	{
		if (tr[u].tag <= x) return;
		if (tr[u].l >= l and tr[u].r <= r)
		{
			tr[u].tag = x;
			return;
		}
		int mid = tr[u].l + tr[u].r >> 1;
		if (l <= mid) update(u << 1, l, r, x);
		if (r > mid) update(u << 1 | 1, l, r, x);
	}
	int query(int u, int x)
	{
		if (tr[u].l == tr[u].r)
		{
			return tr[u].tag;
		}	
		int mid = tr[u].l + tr[u].r >> 1, res = tr[u].tag;
		if (x <= mid) res = min(res, query(u << 1, x));
		else res = min(res, query(u << 1 | 1, x));
		return res;
	}
}sgt;

array<int, N> val;
array<int, N> mindep, md, minx, vt, s, s2;

void dfs2(int u, int fa)
{
	minx[u] = (int)1e9;
	md[u] = 0;
	mindep[u] = (int)1e9;
	if (!val[u]) mindep[u] = dep[u];
	for (auto &j : G[u])
	{
		if (j == fa) continue;
		dfs2(j, u);
		mindep[u] = min(mindep[u], mindep[j]);
		md[u] = max(md[u], md[j] + 1);
	} 
}

inline bool check(int x)
{
	sgt.build(1, 1, n);
	for (int i = 1; i <= n; i++) f[i] = g[i] = h[i] = 0, val[i] = (i > x), vt[i] = -1, s[i] = s2[i] = 0;
	dfs2(r, 0);
	for (int i = 1; i <= n; i++)
	{
		vector<int> ve;
		for (auto &x : G[i])
		{
			if (x == faf[i][0]) continue;
			if (mindep[x] - dep[i] <= b) ve.emplace_back(x);
		}
		if (val[i] == 1 && ve.size() == 1) vt[i] = ve[0];
	}
	for (auto &[u, type, tmp] : ve)
	{
		if (type == 0)
		{
			if (son[u].empty())
			{
				f[u] = (mindep[u] - dep[u] <= b ? 0 : 1);
			}
			else
			{
				int maxn = 0;
				for (auto &j : son[u])
				{
					maxn = max(maxn, g[j]);
				}
				f[u] = maxn;
			}
			if (!f[u]) minx[u] = dep[u];
			for (auto &j : G[u])
			{
				if (j != faf[u][0]) minx[u] = min(minx[u], minx[j]);
			}
			int minn = (int)1e9, secmin = (int)1e9;
			for (auto &j : G[u])
			{
				if (j == faf[u][0]) continue;
				if (minx[j] < minn)
				{
					secmin = minn, minn = minx[j];
				}
				else if (minx[j] < secmin) secmin = minx[j];
			}
			for (auto &j : G[u])
			{
				if (j == faf[u][0]) continue;
				int mins = (minn == minx[j] ? secmin : minn);
				sgt.update(1, dfn[j], dfn[j] + sz[j] - 1, mins - 2 * dep[u]);
			}
		}
		else if (type == 1)
		{
			int cnt = 0, fa = faf[u][0], maxn = 0;
			if (!fa) continue;
			maxn = (s[fa] - s2[u] == 0 ? 0 : 1);
			cnt = (son[fa].empty() ? 0 : (dfn[son[fa][0]] >= dfn[u] && dfn[son[fa].back()] < dfn[u] + sz[u] ? 0 : 1));
			if (cnt == 0)
			{
				if (u == vt[fa]) h[u] = 1;
				else if (mindep[fa] - dep[fa] > b) h[u] = 1;
				else h[u] = 0;
			}
			else h[u] = maxn;
			if (h[u] == 0)
			{
				sgt.update(1, dfn[u], dfn[u] + sz[u] - 1, (int)-1e9);
			}
		}
		else
		{
			int val = sgt.query(1, dfn[u]) + dep[u];
			if (val <= b || minx[u] - dep[u] <= b) g[u] = 0;
			else g[u] = 1;
			if (g[u] == 1)
			{
				int pos = da[u];
				s[pos]++;
				int gpos = dsa[u];
				s2[gpos]++;
			}
		}
	}
	return (f[r] == 0);
} 

int main()
{
	freopen("nim.in", "r", stdin);
	freopen("nim.out", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> r >> a >> b;
	if (a <= b)
	{
		cout << "1\n";
		return 0;
	}
	for (int i = 1; i < n; i++)
	{
		int u, v;
		cin >> u >> v;
		G[u] += v, G[v] += u;
	}
	dfs(r, 0);
	for (int j = 1; j < 20; j++)
	{
		for (int i = 1; i <= n; i++) faf[i][j] = faf[faf[i][j - 1]][j - 1];
	}
	for (int i = 1; i <= n; i++)
	{
		da[i] = get_k_fa(i, a);
		dsa[i] = get_k_fa(i, a - 1);
		son[get_k_fa(i, a)].emplace_back(i);
		ve += Op(i, 0, dep[i]);
		ve += Op(i, 1, dep[i] - 1);
		ve += Op(i, 2, dep[i] - b);
	}
	sort(ve.begin(), ve.end());
	for (int i = 1; i <= n; i++) sort(son[i].begin(), son[i].end(), [&](const int& x, const int& y){return dfn[x] < dfn[y];}); 
	int l = 1, r = n, ans = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << "\n";
	return 0;
}